package wrappers;

import views.ViewElement;
import java.util.*;
import views.TextElement;

/**
 *
 * @author KAV
 */
public class DepartmentWrap extends AbstractWrap {

    public static int IDR = 2;
    private ViewElement viewCountry;
    private int id;
    private String title;
    private int country;

    public DepartmentWrap() {
        title = "";
    }

    public DepartmentWrap(int id, String title, int country) {
        this.id = id;
        this.title = title;
        this.country = country;
    }

    public void setViewCountry(ViewElement _country) {
        viewCountry = _country;
    }

    public int getId() {
        return id;
    }

    public String getTitle() {
        return title;
    }

    public int getCountry() {
        return country;
    }

    public ViewElement getViewId() {
        return new TextElement("id", Integer.toString(id));
    }

    public ViewElement getViewTitle() {
        return new TextElement("title", title);
    }

    public ViewElement getViewCountry() {
        return viewCountry;
    }

    @Override
    public int compareTo(Object o) {
        int result = 0;
        DepartmentWrap ew = (DepartmentWrap) o;
        switch (ss.getParam()) {
            case 0:
                result = (ss.isAscending()) ? (id - ew.id) : (ew.id - id);
                break;
            case 1:
                result = (ss.isAscending()) ? (title.compareTo(ew.title)) : (ew.title.compareTo(title));
                break;
            case 2:
                result = (ss.isAscending()) ? (country - ew.country) : (ew.country - country);
                break;
        }
        return result;
    }

    @Override
    public List<String> getHeaders() {
        List<String> headers = new LinkedList<String>();
        headers.add(getViewId().getHeader());
        headers.add(getViewTitle().getHeader());
        headers.add(getViewCountry().getHeader());
        return headers;
    }

    @Override
    public List<ViewElement> getCells() {
        List<ViewElement> cells = new LinkedList<ViewElement>();
        cells.add(getViewId());
        cells.add(getViewTitle());
        cells.add(getViewCountry());
        return cells;
    }

    @Override
    public String getPrimaryKey() {
        return Integer.toString(id);
    }
}
